﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BUS;
using System.Data;
namespace AirPlane
{
    public partial class TimKiemChuyenBay : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack == false)
            {
                if (Request["maSanBayDi"] != null && Request["maSanBayDen"] != null && Request["thoiGianDi"] != null && Request["thoiGianDen"] != null && Request["type"] != null) 
                {
                    TimChuyenBay(Request["maSanBayDi"].ToString(), Request["maSanBayDen"].ToString(), Request["thoiGianDi"].ToString(), Request["thoiGianDen"].ToString(), int.Parse(Request["type"].ToString()));
                }
            }
         
        }

        public void TimChuyenBay(string maSanBayDi, string maSanBayDen, string thoiGianDi,string thoiGianVe,int type)
        {
            ChuyenBayBUS bus = new ChuyenBayBUS();
            DataTable dt = new DataTable();
            DataTable dt1 = new DataTable();
            dt = bus.TimKiemChuyenBay(maSanBayDi, maSanBayDen, thoiGianDi);
            dt1 = bus.TimKiemChuyenBay(maSanBayDen, maSanBayDi, thoiGianVe);
            if (dt.Rows.Count == 0)
                lbThongBaoDi.Text = "Không tìm thấy chuyến bay đi!";
            else
                lbChuyenBayDi.Text = "Chuyến Bay Đi";
            
           
            gwTimKiem.DataSource = dt;
            gwTimKiem.DataBind();
            if (type == 1)
            {
                if (dt1.Rows.Count == 0)
                    lbThongBaoVe.Text = "Không tìm thấy chuyến bay Về!";
                else
                    lbchuyenBayVe.Text = "Chuyến Bay Về";
               
                gw_TimChuyenBayVe.DataSource = dt1;
                gw_TimChuyenBayVe.DataBind();
            }
        }
    }


}